package com.feeyo.prophet.actions.flight;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.feeyo.llm.agent.engine.*;
import com.feeyo.llm.util.JsonUtil;
import com.feeyo.prophet.pojo.action.DynamicDateRange;
import com.feeyo.prophet.pojo.action.flight.FlightDynamic;
import com.feeyo.prophet.pojo.action.flight.FlightDynamicResp;
import com.feeyo.prophet.pojo.action.flight.FlightScheduleResp;
import com.feeyo.prophet.pojo.action.functioncall.Properties;
import com.feeyo.prophet.pojo.action.functioncall.flight.FlightDynamicProperties;
import com.feeyo.prophet.pojo.action.functioncall.FunctionCall;
import com.feeyo.prophet.pojo.action.functioncall.ItemsBean;
import com.feeyo.prophet.pojo.action.functioncall.flight.common.BasicTypeDefaultList;
import com.feeyo.prophet.config.ParametersSingletonManager;
import com.feeyo.prophet.plugins.*;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;

import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * 1.
 * @author lihu
 */

@Slf4j
public class FlightDynamicAction implements Action {

    private final String host;
    private final Integer port;
    private final String scheduleHost;
    private final String riakLocalHost;
    private final String bucket;

    public FlightDynamicAction(String host, Integer port, String scheduleHost, String riakLocalHost, String bucket) {
        this.host = host;
        this.port = port;
        this.scheduleHost = scheduleHost;
        this.bucket = bucket;
        this.riakLocalHost = riakLocalHost;
    }

    /**
     * 状态枚举
     */
    public static final Map<Integer, String> STATUS_MAP = new HashMap<>();
    static {
        STATUS_MAP.put(0, "计划");
        STATUS_MAP.put(1, "起飞");
        STATUS_MAP.put(2, "到达");
        STATUS_MAP.put(3, "取消");
        STATUS_MAP.put(4, "延误");
        STATUS_MAP.put(5, "备降");
        STATUS_MAP.put(11, "返航");
        STATUS_MAP.put(90, "失事");
        STATUS_MAP.put(91, "失联");
        STATUS_MAP.put(13, "延误预警");
        STATUS_MAP.put(14, "取消预警");
        STATUS_MAP.put(15, "正在备降");
        STATUS_MAP.put(17, "正在返航");
        STATUS_MAP.put(22, "延误预警");
        STATUS_MAP.put(31, "备降起飞");
        STATUS_MAP.put(32, "备降到达");
        STATUS_MAP.put(33, "备降取消");
        STATUS_MAP.put(41, "返航起飞");
        STATUS_MAP.put(42, "返航到达");
        STATUS_MAP.put(43, "返航取消");
        STATUS_MAP.put(70, "转场");
        STATUS_MAP.put(73, "提前取消");
    }

    @Override
    public String human() {
        return "航班信息查询";
    }

    @Override
    public String name() {
        return "FlightDynamicAction";
    }

    @Override
    public String eg() {
        return """
                Question: ZH1316航班6月8号航班信息
                Thought: 我应该使用FlightDynamicAction工具来查找航班信息
                Action: FlightDynamicAction
                Action Input: {"flightDate":"2024-06-01","fnum":"HU7248"}
                """;
    }

    @Override
    public String description() {
        return """
                用于客运或货运航班信息查询。给定航班日期,飞机航班号,出发落地城市，航司等条件,使用此工具查询飞机状态,登机口,航站楼,接机区域,值机柜台,行李转盘号,飞行时间,起飞时间,落地时间。注意，使用该工具要明确货运还是客运，航班号,飞机编号,出发地到达地, 航司四种维度至少存在一项，该工具不支持国家维度查询。
                """;
    }

    @Override
    public String parameters() {
        String parameters = ParametersSingletonManager.getParameters("FlightDynamicAction", () -> {
            FunctionCall functionCall = new FunctionCall();
            functionCall.setType("object");
            functionCall.setRequired(Lists.newArrayList("dateRanges", "fields", "dataType"));
            FlightDynamicProperties properties = new FlightDynamicProperties();
            Properties dateProp = new Properties();
            dateProp.setFlightDate(new BasicTypeDefaultList("string", "航班日期，格式: yyyy-MM-dd，例如: '2024-06-01'"));
            dateProp.setStartTime(new BasicTypeDefaultList("string", "航班开始时间，格式: HH:mm，例如: '12:30'。注意：此字段是可选的。"));
            dateProp.setEndTime(new BasicTypeDefaultList("string", "航班结束时间，格式: HH:mm，例如: '15:15'。注意：此字段是可选的。"));
            properties.setDateRanges(new BasicTypeDefaultList("array", "查询日期范围数组，例如: [{'flightDate': '2024-06-01', 'startTime': '12:30', 'endTime': '15:15'}]", new ItemsBean("object", null, dateProp, Lists.newArrayList("flightDate"))));
            properties.setFnums(new BasicTypeDefaultList("array", "航班号，例如: ['HU7248']。注意：航班号不同与飞机编号和航司。", new ItemsBean("string")));
            properties.setAnums(new BasicTypeDefaultList("array", "飞机编号，例如: ['7248']。注意：飞机编号不同于航班号和航司。", new ItemsBean("string")));
            properties.setAirlines(new BasicTypeDefaultList("array", "航司 IATA 二字码，例如: ['9C']。注意：航司不同于航班号和飞机编号。", new ItemsBean("string")));
            properties.setDepCityCodes(new BasicTypeDefaultList("string", "出发城市 IATA 三字码，例如: 'BJS'"));
            properties.setArrCityCodes(new BasicTypeDefaultList("string", "到达城市 IATA 三字码，例如: 'TYO'"));
            properties.setFcategory(new BasicTypeDefaultList("array", "航段类型数组 以下枚举值均表示双向航班：'0:国内-国内(有时直接简述为国内),1:国内-地区(有时直接简述为地区),2:国内-国际(有时直接简述为国际),3:地区-地区,4:地区-国际,5:国际-国际'", new ItemsBean("number", Lists.newArrayList(0, 1, 2, 3, 4, 5))));
            properties.setFservice(new BasicTypeDefaultList("string", "服务类型，枚举值: 'F: 货运; J: 客运'", Lists.newArrayList("F", "J")));
            properties.setDataType(new BasicTypeDefaultList("boolean", "是否给出所有数据，枚举值: 'false: 非所有数据; true: 所有数据'", false, Lists.newArrayList(false, true)));
            List<ResultScheme.ResultAttach> resultAttachList = result().getResultAttachList();
            List<String> fieldsList = resultAttachList.stream().map(ResultScheme.ResultAttach::getName).toList();
            properties.setFields(new BasicTypeDefaultList("array", "返回结果字段集合(根据需要多选), 各个字段含义解释如下: " + JsonUtil.marshalToString(resultAttachList)
                    + "。可选填字段如下: " + String.join(", ", fieldsList) + ",你需要尽量全面的选出适用字段。可以选多，不要选少。", new ItemsBean("string"), 1));
            functionCall.setProperties(properties);
            return functionCall.toString();
        });
        return parameters;
    }
    @Override
    public ParameterScheme defaultParameters() {
        Map<String, ParameterScheme.Property> properties = new HashMap<>();
        ParameterScheme.Property dateRangesProperty = new ParameterScheme.Property();
        dateRangesProperty.setType("array");
        dateRangesProperty.setDescription("查询日期范围数组，例如: [{'flightDate': '2024-06-01', 'startTime': '12:30', 'endTime': '15:15'}]");
        ParameterScheme.Property.Items dateRangesItems = new ParameterScheme.Property.Items();
        dateRangesItems.setType("object");
        Map<String, ParameterScheme.Property> dateRangesItemsProperties = new HashMap<>();
        dateRangesItemsProperties.put("flightDate", new ParameterScheme.Property("string", "航班日期，格式: yyyy-MM-dd，例如: '2024-06-01'"));
        dateRangesItemsProperties.put("startTime", new ParameterScheme.Property("string", "航班开始时间，格式: HH:mm，例如: '12:30'"));
        dateRangesItemsProperties.put("endTime", new ParameterScheme.Property("string", "航班结束时间，格式: HH:mm，例如: '15:15'"));
        dateRangesItems.setProperties(dateRangesItemsProperties);
        dateRangesItems.setRequired(List.of("flightDate"));
        dateRangesProperty.setItems(dateRangesItems);
        properties.put("dateRanges", dateRangesProperty);
        properties.put("fnums", new ParameterScheme.Property("array", "航班号，例如: ['HU7248']。注意：航班号不同与飞机编号和航司。", new ParameterScheme.Property.Items("string", null, null, null), null, null, null, null));
        properties.put("anums", new ParameterScheme.Property("array", "飞机编号，例如: ['7248']。注意：飞机编号不同于航班号和航司", new ParameterScheme.Property.Items("string", null, null, null), null, null, null, null));
        properties.put("airlines", new ParameterScheme.Property("array", "航司IATA二字码，例如: ['9C']。注意：航司不同与航班号和飞机编号。", new ParameterScheme.Property.Items("string", null, null, null), null, null, null, null));
        properties.put("depCodes", new ParameterScheme.Property("string", "出发城市IATA三字码，例如: 'BJS'"));
        properties.put("arrCodes", new ParameterScheme.Property("string", "到达城市IATA三字码，例如: 'TYO'"));
        properties.put("fcategory", new ParameterScheme.Property("array", "航段类型数组 枚举值:'0:国内飞国内(有时直接简述为国内),1:国内飞地区(有时直接简述为地区),2:国内飞国际(有时直接简述为国际),3:地区飞地区,4:地区飞国际,5:国际飞国际'", new ParameterScheme.Property.Items("number", List.of(0, 1, 2, 3, 4, 5), null, null), null, null, null, null));
        properties.put("fservice", new ParameterScheme.Property("string", "服务类型，枚举值: 'F: 货运; J: 客运'", null, null, List.of("F", "J"), null, null));
        properties.put("dataType", new ParameterScheme.Property("boolean", "是否输出全量数据，枚举值: 'false: 非全量; true: 全量'", null, "false", null, null, null));
        List<ResultScheme.ResultAttach> resultAttachList = result().getResultAttachList();
        List<String> fieldsList = resultAttachList.stream().map(ResultScheme.ResultAttach::getName).toList();
        properties.put("fields", new ParameterScheme.Property("array", "返回结果字段集合(根据需要多选), 字段含义: " + JsonUtil.marshalToString(resultAttachList)
                + "，可选字段: " + String.join(", ", fieldsList), new ParameterScheme.Property.Items("string", null, null, null), null, null, 1, null));
        ParameterScheme parameterScheme = new ParameterScheme("object", List.of("dateRanges", "fields", "dataType"), properties);
        return parameterScheme;
    }
    @Override
    public ResultScheme result() {
        ResultScheme resultScheme = new ResultScheme();
        List<ResultScheme.ResultAttach> resultAttachList = Lists.newArrayList();
        resultAttachList.add(new ResultScheme.ResultAttach("forg", "string", "出发地IATA三字码"));
        resultAttachList.add(new ResultScheme.ResultAttach("fdst", "string", "到达地IATA三字码"));
        resultAttachList.add(new ResultScheme.ResultAttach("departureTerminal", "string", "出发航站楼"));
        resultAttachList.add(new ResultScheme.ResultAttach("arrivalTerminal", "string", "到达航站楼"));
        resultAttachList.add(new ResultScheme.ResultAttach("scheduledDeptime", "string", "计划出发时间, UTC+8时间"));
        resultAttachList.add(new ResultScheme.ResultAttach("scheduledArrtime", "string", "计划到达时间, UTC+8时间"));
        resultAttachList.add(new ResultScheme.ResultAttach("actualDeptime", "string", "实际出发当地时间"));
        resultAttachList.add(new ResultScheme.ResultAttach("actualArrtime", "string", "实际到达当地时间, 统计维度需要转化成实际出发地当地时间"));
        resultAttachList.add(new ResultScheme.ResultAttach("fservice", "string", "飞机类型 enum:'F:货运;J:客运'"));
        resultAttachList.add(new ResultScheme.ResultAttach("flightStatusCode", "integer", "飞机状态 enum:'0:计划;1:起飞;2:达到;3:取消;4:延误;5:备降'"));
        resultAttachList.add(new ResultScheme.ResultAttach("fnum", "string", "航班号"));
        resultAttachList.add(new ResultScheme.ResultAttach("checkinDeskRange", "string", "值机柜台号"));
        resultAttachList.add(new ResultScheme.ResultAttach("latestCheckInDeadline", "string", "最新签到截止日期"));
        resultAttachList.add(new ResultScheme.ResultAttach("tdoor", "string", "门禁信息"));
        resultAttachList.add(new ResultScheme.ResultAttach("baggageReclaimCarousel", "string", "行李转盘号"));
        resultAttachList.add(new ResultScheme.ResultAttach("todayPunctRate", "string", "当日准点率"));
        resultAttachList.add(new ResultScheme.ResultAttach("flytime", "string", "飞行时间: 单位秒"));
        resultAttachList.add(new ResultScheme.ResultAttach("airCName","string","航司中文名称"));
        resultAttachList.add(new ResultScheme.ResultAttach("airline","string","航司"));
        resultScheme.setResultAttachList(resultAttachList);
        return resultScheme;

    }

    /**
     * 航班动态查询
     * 航班号(fnumList), 飞机编号(anumList), 出发地到达地(depCodes, arrCodes), 航司(airline) 四种维度
     */
    @Override
    public ActionResult run(String question, String input,ExecuteOptions options) {
        try {
            FlightDynamic req = JSON.parseObject(input, FlightDynamic.class);
            List<DynamicDateRange> dateRanges = req.getDateRanges();
            // 获取各个维度的条件
            List<Integer> fcategory = req.getFcategory();
            List<String> fnumList = req.getFnums();
            List<String> anumList = req.getAnums();
            List<String> airlineList = req.getAirlines();
            String fservice = req.getFservice();
            List<String> fields = req.getFields();
            // 出发城市,到达城市
            List<String> depCodeList = Lists.newArrayList();
            List<String> arrCodeList = Lists.newArrayList();
            if (StringUtils.isNotEmpty(req.getDepCityCodes())) {
                depCodeList = FleetAttributesActionUtils.getAirportIata(host, port, req.getDepCityCodes());
            }
            if (StringUtils.isNotEmpty(req.getArrCityCodes())) {
                arrCodeList = FleetAttributesActionUtils.getAirportIata(host, port, req.getArrCityCodes());
            }
            int pageNum = req.getPageNum() == null ? ConstantUtils.COMMON_INT_ZERO : req.getPageNum();
            if (pageNum <= ConstantUtils.COMMON_INT_ZERO) {
                pageNum = ConstantUtils.COMMON_INT_ONE;
            }
            int pageSize = req.getPageSize() == null ? ConstantUtils.COMMON_INT_TEN : req.getPageSize();
            boolean dataType = req.isDataType();
            if (CollectionUtils.isEmpty(dateRanges)) {
                return new ActionResult( HttpStatus.BAD_REQUEST.value(), "航班日期不能为空");
            }
            if (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList) || CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) {
                return new ActionResult( HttpStatus.BAD_REQUEST.value(), "出发地,到达地必须同时存在");
            }
            // 按照 航班号(fnumList), 飞机编号(anumList), 出发地到达地(depCodes, arrCodes), 航司(airline) 四种维度条件排列组合调用接口(每种排列组合调用的接口可能不一样. 用TODO代替就行).
            // 00. 0000
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                return new ActionResult( HttpStatus.BAD_REQUEST.value(), "航班号,飞机编号,出发地到达地, 航司四种维度至少存在一项");
            }
            // 01. 0001
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    // data
                    for (String airline : airlineList) {
                        String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, null, null, null, null, airline);
                        if (StringUtils.isEmpty(respTxt)) {
                            continue;
                        }
                        flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 02. 0010
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String depCode : depCodeList) {
                        for (String arrCode : arrCodeList) {
                            String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, null, null, depCode, arrCode, null);
                            if (StringUtils.isEmpty(respTxt)) {
                                continue;
                            }
                            flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                            if (CollectionUtils.isEmpty(flightStatisticsResp)) {
                                String queryScheduleData = DbSearchActionUtils.queryFlightSchedule(scheduleHost, null, depCode, arrCode, flightDate);
                                flightScheduleData(flightDate, startTime, flightStatisticsResp, queryScheduleData);
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 03. 0011
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String depCode : depCodeList) {
                        for (String arrCode : arrCodeList) {
                            for (String airline : airlineList) {
                                String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, null, null, depCode, arrCode, airline);
                                if (StringUtils.isEmpty(respTxt)) {
                                    continue;
                                }
                                flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 04. 0100
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                // 飞机编号
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String anum : anumList) {
                        String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, null, anum, null, null, null);
                        if (StringUtils.isEmpty(respTxt)) {
                            continue;
                        }
                        flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 05. 0101
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String anum : anumList) {
                        for (String airline : airlineList) {
                            String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, null, anum, null, null, airline);
                            if (StringUtils.isEmpty(respTxt)) {
                                continue;
                            }
                            flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 06. 0110
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String anum : anumList) {
                        for (String depCode : depCodeList) {
                            for (String arrCode : arrCodeList) {
                                String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, null, anum, depCode, arrCode, null);
                                if (StringUtils.isEmpty(respTxt)) {
                                    continue;
                                }
                                flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 07. 0111
            if (CollectionUtils.isEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String anum : anumList) {
                        for (String depCode : depCodeList) {
                            for (String arrCode : arrCodeList) {
                                for (String airline : airlineList) {
                                    String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, null, anum, depCode, arrCode, airline);
                                    if (StringUtils.isEmpty(respTxt)) {
                                        continue;
                                    }
                                    flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                                }
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 08. 1000
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, null, null, null, null);
                        flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                        // 查航班接口, 数据融合
                        if (CollectionUtils.isEmpty(flightStatisticsResp)) {
                            String queryScheduleData = DbSearchActionUtils.queryFlightSchedule(scheduleHost, fnum, null, null, flightDate);
                            flightScheduleData(flightDate, startTime, flightStatisticsResp, queryScheduleData);
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 09. 1001
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        for (String airline : airlineList) {
                            String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, null, null, null, airline);
                            if (StringUtils.isEmpty(respTxt)) {
                                continue;
                            }
                            flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 10. 1010
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                // 航司 + 出发地,到达地
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        for (String depCode : depCodeList) {
                            for (String arrCode : arrCodeList) {
                                String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, null, depCode, arrCode, null);
                                if (StringUtils.isEmpty(respTxt)) {
                                    continue;
                                }
                                flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                                if (CollectionUtils.isEmpty(flightStatisticsResp)) {
                                    String queryScheduleData = DbSearchActionUtils.queryFlightSchedule(scheduleHost, fnum, depCode, arrCode, flightDate);
                                    flightScheduleData(flightDate, startTime, flightStatisticsResp, queryScheduleData);
                                }
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 11. 1011
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                // 航司 + 出发地,到达地
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        for (String depCode : depCodeList) {
                            for (String arrCode : arrCodeList) {
                                for (String airline : airlineList) {
                                    String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, null, depCode, arrCode, airline);
                                    if (StringUtils.isEmpty(respTxt)) {
                                        continue;
                                    }
                                    flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                                }
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 12. 1100
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        for (String anum : anumList) {
                            String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, anum, null, null, null);
                            if (StringUtils.isEmpty(respTxt)) {
                                continue;
                            }
                            flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 13. 1101
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isEmpty(depCodeList) && CollectionUtils.isEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        for (String anum : anumList) {
                            for (String airline : airlineList) {
                                String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, anum, null, null, airline);
                                if (StringUtils.isEmpty(respTxt)) {
                                    continue;
                                }
                                flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 14. 1110
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        for (String anum : anumList) {
                            for (String depCode : depCodeList) {
                                for (String arrCode : arrCodeList) {
                                    String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, anum, depCode, arrCode, null);
                                    if (StringUtils.isEmpty(respTxt)) {
                                        continue;
                                    }
                                    flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                                }
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            // 15. 1111
            if (CollectionUtils.isNotEmpty(fnumList) && CollectionUtils.isNotEmpty(anumList) && (CollectionUtils.isNotEmpty(depCodeList) && CollectionUtils.isNotEmpty(arrCodeList)) && CollectionUtils.isNotEmpty(airlineList)) {
                List<FlightDynamicResp> flightStatisticsResp = Lists.newArrayList();
                for (DynamicDateRange dateRange : dateRanges) {
                    String flightDate = dateRange.getFlightDate();
                    String startTime = dateRange.getStartTime();
                    String endTime = dateRange.getEndTime();
                    String startTimeStamp = null;
                    if (StringUtils.isNotEmpty(startTime)) {
                        startTimeStamp = getTimeStamp(flightDate + " " + startTime);
                    }
                    String endTimeStamp = null;
                    if (StringUtils.isNotEmpty(endTime)) {
                        endTimeStamp = getTimeStamp(flightDate + " " + endTime);
                    }
                    for (String fnum : fnumList) {
                        for (String anum : anumList) {
                            for (String depCode : depCodeList) {
                                for (String arrCode : arrCodeList) {
                                    for (String airline : airlineList) {
                                        String respTxt = DbSearchActionUtils.queryFlightDynamicData(host, port, flightDate, startTimeStamp, endTimeStamp, fservice, fcategory, fnum, anum, depCode, arrCode, airline);
                                        if (StringUtils.isEmpty(respTxt)) {
                                            continue;
                                        }
                                        flightStatisticsResp.addAll(getFlightDynamicData(respTxt));
                                    }
                                }
                            }
                        }
                    }
                }
                return getDynamicActionResult(flightStatisticsResp, fields, dataType, pageNum, pageSize, input);
            }
            return new ActionResult( HttpStatus.BAD_REQUEST.value(), "暂不支持这种条件查询");
        } catch (Throwable e) {
            log.error("error", e);
            return new ActionResult(HttpStatus.INTERNAL_SERVER_ERROR.value(), "解析发生错误，请思考后再调用？");
        }
    }

    private void flightScheduleData(String flightDate, String startTime, List<FlightDynamicResp> flightStatisticsResp, String queryScheduleData) {
        if (StringUtils.isNotEmpty(queryScheduleData)) {
            List<FlightScheduleResp> flightScheduleResp = getFlightScheduleRespData(queryScheduleData);
            if (StringUtils.isNotEmpty(startTime)) {
                flightScheduleResp = flightScheduleResp.stream().filter(v -> LocalTime.parse(v.getFdeptime()).isAfter(LocalTime.parse(startTime))).toList();
            }
            for (FlightScheduleResp flightSchedule : flightScheduleResp) {
                String fdeptimeStamp = getTimeStamp(flightDate + " " + flightSchedule.getFdeptime());
                String farrtimeStamp = getTimeStamp(flightDate + " " + flightSchedule.getFarrtime());
                Optional<FlightDynamicResp> firstOptional = flightStatisticsResp.stream().filter(flightDynamic -> flightDynamic.getForg().equals(flightSchedule.getForg()) && flightDynamic.getFdst().equals(flightSchedule.getFdst())
                        && flightDynamic.getFnum().equals(flightSchedule.getFnumber()) && flightDynamic.getScheduledDeptime().equals(fdeptimeStamp) && flightDynamic.getScheduledArrtime().equals(farrtimeStamp)).findFirst();
                if (firstOptional.isEmpty()) {
                    flightStatisticsResp.add(getDynamicBySchedule(flightSchedule, fdeptimeStamp, farrtimeStamp));
                }
            }
        }
    }

    /**
     * 数据查询结果解析
     */
    private List<FlightDynamicResp> getFlightDynamicData(String respTxt) {
        List<FlightDynamicResp> respList = Lists.newArrayList();
        if (StringUtils.isEmpty(respTxt)) {
            return respList;
        }
        JSONObject json = JSON.parseObject(respTxt);
        JSONObject data = json.getJSONObject("data");
        if (null == data) {
            return respList;
        }
        JSONArray rowArray = data.getJSONArray("rows");
        if (rowArray != null) {
            if (!rowArray.isEmpty()) {
                for (Object row : rowArray) {
                    respList.add(JSON.parseObject(String.valueOf(row), FlightDynamicResp.class));
                }
            }
        }
        return respList;
    }

    /**
     * 数据处理
     */
    private List<FlightScheduleResp> getFlightScheduleRespData(String respTxt) {
        List<FlightScheduleResp> respList = Lists.newArrayList();
        JSONObject json = JSON.parseObject(respTxt);
        JSONArray rowArray = json.getJSONArray("data");
        if (!rowArray.isEmpty()) {
            for (Object row : rowArray) {
                respList.add(JSON.parseObject(String.valueOf(row), FlightScheduleResp.class));
            }
        }
        return respList;
    }

    /**
     * 时间戳
     */
    private static String getTimeStamp(String dateTimeStr) {
        // 定义日期时间格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        // 解析日期时间字符串为 LocalDateTime
        LocalDateTime localDateTime = LocalDateTime.parse(dateTimeStr, formatter);
        // 将 LocalDateTime 转换为时间戳（以毫秒为单位）
        return localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000 + "";
    }

    private static FlightDynamicResp getDynamicBySchedule(FlightScheduleResp flightSchedule, String fdeptTime, String farrTime) {
        FlightDynamicResp flightDynamicResp = new FlightDynamicResp();
        flightDynamicResp.setForg(flightSchedule.getForg());
        flightDynamicResp.setFdst(flightSchedule.getFdst());
        flightDynamicResp.setFnum(flightSchedule.getFnumber());
        flightDynamicResp.setScheduledDeptime(fdeptTime);
        flightDynamicResp.setScheduledArrtime(farrTime);
//        flightDynamicResp.setShareExecuteFlag(String.valueOf(flightSchedule.getFcodeshared()));
//        flightDynamicResp.setShareFlight(flightSchedule.getFcodesharenumber());
        flightDynamicResp.setAirline(flightSchedule.getFaircode());
//        flightDynamicResp.setFcategory((int) flightSchedule.getFcategory());
//        flightDynamicResp.setFservice(flightSchedule.getFservice());
        flightDynamicResp.setFtype(flightSchedule.getFtype());
//        flightDynamicResp.setPortsOfCall(String.valueOf(flightSchedule.getFstop()));
        flightDynamicResp.setFood(flightSchedule.getFood());
        if (flightSchedule.isCancelled()) {
            flightDynamicResp.setFlightStatus(STATUS_MAP.get(3));
        } else {
            flightDynamicResp.setFlightStatus(STATUS_MAP.get(0));
        }
        return flightDynamicResp;
    }


    /**
     * 数据返回
     */
    private ActionResult getDynamicActionResult(List<FlightDynamicResp> flightStatisticsResp, List<String> fields, boolean dataType, int pageNum, int pageSize, String input) throws Exception {
        // 分页数据处理
        ResultScheme resultScheme = FlightScheduleActionUtils.resultScheme(fields, result());
        flightStatisticsResp.sort(Comparator.comparing(FlightDynamicResp::getScheduledDeptime));
        // 数据日期值处理, 时间戳处理成正常
        flightStatisticsResp.forEach(v -> {
            v.setScheduledDeptime(v.getScheduledDeptime() != null ? FlightScheduleActionUtils.timeStampToShanghai(Long.valueOf(v.getScheduledDeptime())) : null);
            v.setScheduledArrtime(v.getScheduledArrtime() != null ? FlightScheduleActionUtils.timeStampToShanghai(Long.valueOf(v.getScheduledArrtime())) : null);
            v.setActualDeptime(v.getActualDeptime() != null ? FlightScheduleActionUtils.timeStampToShanghai(Long.valueOf(v.getActualDeptime())) : null);
            v.setActualArrtime(v.getActualArrtime() != null ? FlightScheduleActionUtils.timeStampToShanghai(Long.valueOf(v.getActualArrtime())) : null);
            v.setLatestCheckInDeadline(v.getLatestCheckInDeadline() != null ? FlightScheduleActionUtils.timeStampToShanghai(Long.valueOf(v.getLatestCheckInDeadline())) : null);
        });

        List<JSONObject> needFlightStatisticsResp = FlightScheduleActionUtils.getNeedDataList(fields, flightStatisticsResp);
        // 全量数据
        if (dataType && needFlightStatisticsResp.size() > 10) {
            List<Map<String, Object>> dymanicList = getDymanicList(needFlightStatisticsResp);
            String fileUrl = DbSearchActionUtils.generateUrl(riakLocalHost, bucket, dymanicList);
            AttachObj attachObj = new AttachObj(AttachObj.Type.Link, "点击查看全量数据", fileUrl);
            return AnswerUtils.subContentAnswer(name(), input, attachObj, "请对以下内容进行总结,数据json如下:" + JSON.toJSONString(getFleetDynamicList(needFlightStatisticsResp, 1, 3)), resultScheme);
        }
        return AnswerUtils.answer(name(), input, getFleetDynamicList(needFlightStatisticsResp, pageNum, pageSize), resultScheme);
    }

    /**
     * 数据分页
     *
     * @param flightScheduleList
     * @param startIndex
     * @return
     */
    private List<?> getFleetDynamicList(List<?> flightScheduleList, int startIndex, Integer pageSize) {
        List<?> flightSchedule = Lists.newArrayList();
        int beginIndex = (startIndex - 1) * pageSize;
        int endIndex = Math.min(startIndex * pageSize, flightScheduleList.size());
        // 检查索引是否在列表范围内
        if (beginIndex >= 0 && beginIndex < endIndex) {
            flightSchedule = flightScheduleList.subList(beginIndex, endIndex);
        }
        return flightSchedule;
    }

    /**
     * 把list 转成map， 其中map 的key 是 中文注释”航班号“ 这种
     *
     * @param flightScheduleList
     * @return
     */
    private List<Map<String, Object>> getDymanicList(List<?> flightScheduleList) {
        List<Map<String, Object>> dynamicList = new ArrayList<>();
        for (Object flightSchedule : flightScheduleList) {
            FlightDynamicResp flightDynamicResp = JSONObject.parseObject(flightSchedule.toString(), FlightDynamicResp.class);
            Map<String, Object> flightMap = new HashMap<>();
            Field[] fields = FlightDynamicResp.class.getDeclaredFields();
            for (Field field : fields) {
                field.setAccessible(true);
                try {
                    // 获取字段上的注释
                    String comment = FlightDynamicResp.getFieldComment(field);
                    if (comment != null) {
                        // 获取字段的值
                        Object value = field.get(flightDynamicResp);
                        if (value == null) {
                            continue;
                        }
                        flightMap.put(comment, value);
                    }
                } catch (IllegalAccessException e) {
                    log.error("获取字段值失败", e);
                }
            }
            dynamicList.add(flightMap);
        }
        return dynamicList;
    }

}